package com.ruoyi.graduate.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.graduate.domain.entity.MsPackageType;
import com.ruoyi.graduate.domain.param.MsPackageTypeAddParam;
import com.ruoyi.graduate.domain.param.MsPackageTypeUpdataParam;
import com.ruoyi.graduate.mapper.MsPackageTypeMapper;
import com.ruoyi.graduate.mapping.MsPackageTypeMapping;
import com.ruoyi.graduate.service.IMsPackageTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class IMsPackageTypeServiceImpl extends ServiceImpl<MsPackageTypeMapper, MsPackageType>
implements IMsPackageTypeService {

    @Autowired
    private MsPackageTypeMapper msPackageTypeMapper;


    @Override
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult addMsPackageType(MsPackageTypeAddParam param) {

        MsPackageType add = MsPackageTypeMapping.INSTANCE.add(param);

        int insert = msPackageTypeMapper.insert(add);

        return insert > 0 ? AjaxResult.success() : AjaxResult.error();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult updateMsPackageType(MsPackageTypeUpdataParam param) {

        MsPackageType update = MsPackageTypeMapping.INSTANCE.update(param);

        int updata = msPackageTypeMapper.updateById(update);


        return updata > 0 ? AjaxResult.success() : AjaxResult.error();
    }
}
